package com.base_data_handler.sx.handler;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.logging.Logger;

import org.apache.commons.dbutils.QueryRunner;

import com.base_data_handler.utils.DataSourceUtils;
import com.base_data_handler.utils.DruidPlugin;
import com.base_data_handler.utils.ToolDateTime;
import com.mysql.fabric.xmlrpc.base.Data;

public class SX_DataClear_Handler {
	private	static QueryRunner qr=new QueryRunner(DruidPlugin.getDataSource());

	private static final Logger log = Logger.getLogger(SX_Forcast_Handler.class.getName());
	
	
	public static void delClear() throws SQLException{
		String times="";//20170627000000
		Calendar c=Calendar.getInstance();
		int year=c.get(Calendar.YEAR);
		int month=c.get(Calendar.MONTH)+1;
		int day=c.get(Calendar.DAY_OF_MONTH);
		String hour=c.get(Calendar.HOUR_OF_DAY)+"";
		SimpleDateFormat sm=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		//三天以前的
		
		String time=ToolDateTime.dateAddHours(-3*24-8, sm.format(new Date()));
		  qr.update("delete from cmiss_all_position_hours where datetime<'"+time+"'");
		  qr.update("delete from cmiss_warning where out_data<now()");
		  qr.update("delete from cmiss_focast where create_time<"+ToolDateTime.dateAddHours(-3*24-8,sm.format(new Data())));
		}
	
	public static void main(String[] args) {
		try {
			delClear();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
